home *** CD-ROM | disk | FTP | other *** search
- /*
- * jctype.h
- * for kanji character handling
- */
-
- #ifndef _JCTYPE_H_
- #define _JCTYPE_H_
-
- #include <ctype.h>
-
- #define J_KPUN 0x1 /* punctuation character for JIS kana */
- #define J_KANA 0x2 /* JIS kana charactor */
- #define J_KNJ1 0x4 /* 1st charactor in ms-kanji code */
- #define J_KNJ2 0x8 /* 2st charactor in ms-kanji code */
-
- extern const char _jctype[];
-
- #define iskana(c) ((_jctype + 1)[(c)&0xff]&(J_KANA|J_KPUN))
- #define iskmoji(c) ((_jctype + 1)[(c)&0xff]&J_KANA)
- #define iskanapn(c) ((_jctype + 1)[(c)&0xff]&J_KPUN)
- #define iskalpha(c) ((isascii(c) && isalpha(c)) || iskmoji(c))
- #define iskalnum(c) ((isascii(c) && isalnum(c)) || iskmoji(c))
- #define iskprint(c) ((isascii(c) && isprint(c)) || iskana(c))
- #define iskgraph(c) ((isascii(c) && isgraph(c)) || iskana(c))
- #define iskpunct(c) ((isascii(c) && ispunct(c)) || iskanapn(c))
- #define iskpun iskanapn /* same as LSI-C 86 with MS-DOS */
- #define isalkana iskalpha /* same as LSI-C 86 with MS-DOS */
- #define isalnmkana iskalnum /* same as LSI-C 86 with MS-DOS */
- #define isprkana iskprint /* same as LSI-C 86 with MS-DOS */
- #define isgrkana iskgraph /* same as LSI-C 86 with MS-DOS */
- #define ispnkana iskpunct /* same as LSI-C 86 with MS-DOS */
-
- #define ismsknj(c) ((_jctype + 1)[(c)&0xff]&J_KNJ1)
- #define ismsknj2(c) ((_jctype + 1)[(c)&0xff]&J_KNJ2)
- #define iskanji ismsknj /* same as LSI C-86 with MS-DOS */
- #define iskanji2 ismsknj2 /* same as LSI C-86 with MS-DOS */
-
- int chkmsctype(char, int);
- int nthmsctype(const char *, int);
- #define chkctype chkmsctype /* same as LSI C-86 with MS-DOS */
- #define nthctype nthmsctype /* same as LSI C-86 with MS-DOS */
-
- #define CT_ILGL (-1)
- #define CT_ANK 0
- #define CT_KJ1 1
- #define CT_KJ2 2
-
- unsigned short mstojis(unsigned short);
- unsigned short jistoms(unsigned short);
- #define jmstojis mstojis
- #define jistojms jistoms
-
- #ifndef BOOL
- #define BOOL short
- #endif
- BOOL msknj(unsigned short); /* ms-kanji code, or not */
- #define msknj0(c) (msknj(c) && (c) <= 0x889e) /* symbol, ANK, etc... */
- /* kanji 1st Level */
- #define msknj1(c) (msknj(c) && 0x889f <= (c) && (c) <= 0x9872)
- /* kanji 2nd Level */
- #define msknj2(c) (msknj(c) && 0x989f <= (c) && (c) <= 0xea9e)
- #define jiszen msknj /* same as LSI C-86 with MS-DOS */
- #define jisl0 msknj0 /* same as LSI C-86 with MS-DOS */
- #define jisl1 msknj1 /* same as LSI C-86 with MS-DOS */
- #define jisl2 msknj2 /* same as LSI C-86 with MS-DOS */
-
- #define ismsupper(c) (0x8260 <= (c) && (c) <= 0x8279)
- #define ismslower(c) (0x8281 <= (c) && (c) <= 0x829a)
- #define ismsalpha(c) (ismsupper(c) || ismslower(c))
- #define ismsdigit(c) (0x824f <= (c) && (c) <= 0x8258)
- #define ismskata(c) (0x8340 <= (c) && (c) <= 0x8396 && (c) != 0x837f)
- #define ismshira(c) (0x829f <= (c) && (c) <= 0x82f1)
- #define ismssymbol(c) (0x8141 <= (c) && (c) <= 0x81ac && (c) != 0x817f)
- #define ismsspace(c) ((c) == 0x8140)
- #define jisupper ismsupper /* same as LSI C-86 with MS-DOS */
- #define jislower ismslower /* same as LSI C-86 with MS-DOS */
- #define jisdigit ismsdigit /* same as LSI C-86 with MS-DOS */
- #define jiskata ismskata /* same as LSI C-86 with MS-DOS */
- #define jishira ismshira /* same as LSI C-86 with MS-DOS */
- #define jiskigou ismssymbol /* same as LSI C-86 with MS-DOS */
- #define jisspace ismsspace /* same as LSI C-86 with MS-DOS */
-
- typedef unsigned short u_short;
- extern const u_short _jascii[];
- extern const char _jsymbol[];
-
- #define isjupper(c) (0x2341 <= (c) && (c) <= 0x235a)
- #define isjlower(c) (0x2361 <= (c) && (c) <= 0x237a)
- #define isjalpha(c) (isjupper(c) || isjlower(c))
- #define isjdigit(c) (0x2330 <= (c) && (c) <= 0x2339)
- #define isjalnum(c) (isjalpha(c) || isjdigit(c))
- #define isjkata(c) (0x2521 <= (c) && (c) <= 0x2576)
- #define isjhira(c) (0x2421 <= (c) && (c) <= 0x2473)
- #define isjsymbol(c) ((0x2122 <= (c) && (c) <= 0x217e) || \
- (0x2221 <= (c) && (c) <= 0x222e))
- #define isjspace(c) ((c) == 0x2121)
- #define tojlower(c) ((isjupper(c)) ? (c) + ' ' : 0)
- #define tojupper(c) ((isjlower(c)) ? (c) - ' ' : 0)
- #define tojhira(c) ((isjkata(c)) ? (c) - 0x100 : 0)
- #define tojkata(c) ((isjhira(c)) ? (c) + 0x100 : 0)
-
- #define jistoascii(c) ((isjalnum(c)) ? \
- (c)&0xff : (((((c)>>CHAR_BIT)&0xff) == '!') ? \
- (_jsymbol + 1)[(c)&0x7f] : 0))
- #define asciitojis(c) ((_jascii + 1)[(c)&0x7f])
-
- #endif /* _JCTYPE_H_ */
-